package cn.tedu.hhmc.user.controller;

import cn.tedu.hhmc.base.response.JsonResult;
import cn.tedu.hhmc.patient.pojo.entity.Patient;
import cn.tedu.hhmc.patient.pojo.vo.PatientVO;
import cn.tedu.hhmc.user.pojo.dto.UserLoginParam;
import cn.tedu.hhmc.user.pojo.entity.User;
import cn.tedu.hhmc.user.pojo.vo.UserVO;
import cn.tedu.hhmc.user.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/hhmc/user")
public class UserController {
    @Autowired
    UserService userService;

    @PostMapping("login")
    public JsonResult login(@RequestBody UserLoginParam userLoginParam){
        log.debug("用户登录:参数={}",userLoginParam);
        UserVO userVO = userService.login(userLoginParam);
        return JsonResult.ok(userVO);
    }

    @GetMapping("/list")
    public JsonResult list()
    {
        log.debug("查询所有医生信息列表,参数:无");
        List<UserVO> list = userService.selectUserList(new User());
        return JsonResult.ok(list);
    }

    @GetMapping(value = "/select/{id}")
    public JsonResult selectUserById(@PathVariable("id") Long id)
    {
        log.debug("查询医生信息列表,参数:{}",id);
        return JsonResult.ok(userService.selectUserById(id));
    }
}
